#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
inline int read(){
	register int x=0;
	register char c=getchar();
	for(;!(c>='0'&&c<='9');c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+c-'0';
	return x;
}
int Nxt[maxn],Nxt_[maxn];
int a[maxn],n,cnt;
int L[maxn],R[maxn];
bool k[maxn];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	n=read();
	for(register int i=1;i<=n;i++)
		a[i]=read(),Nxt[i]=i+1;
	L[++cnt]=1;
	for(register int i=2;i<=n;i++)
		if(a[i]!=a[L[cnt]]) R[cnt]=i-1,L[++cnt]=i;
	R[cnt]=R[cnt+1]=n,Nxt_[0]=1;
	for(register int i=1;i<=cnt+2;i++)
		Nxt_[i]=i+1;
	register int ii,Last;
	register bool flag;
	while(Nxt_[0]<=cnt){
		Last=flag=0;
		for(register int i=Nxt_[0],j=0;i<=cnt;j=ii,i=Nxt_[i]){
			printf("%d ",L[i]),L[i]=Nxt[L[i]],Nxt[Last]=L[i];
			if(L[i]>R[i]) {
				if(!j||a[L[j]]!=a[L[Nxt_[i]]]||Nxt_[i]>cnt) 
					Nxt_[j]=Nxt_[i],ii=j,flag=0;
				else Nxt_[j]=Nxt_[Nxt_[i]],R[j]=R[Nxt_[i]],ii=j,flag=1;
			}
			else{
				Last=R[i];
				if(!flag) ii=i;
				else ii=j,flag=0;
			}
			
		}
		printf("\n");
	}
	return 0;
}//henghenghengaaaaaaaaaaaaaaa
